<template>
  <el-card class="statistics-card" :body-style="{ padding: '20px' }">
    <div class="card-header">
      <div class="card-icon" :style="{ backgroundColor: iconColor }">
        <i :class="icon"></i>
      </div>
      <div class="card-content">
        <div class="card-title">{{ title }}</div>
        <div class="card-value">{{ value }}</div>
        <div class="card-trend" :class="trendClass">
          <i :class="trendIcon"></i>
          <span>{{ trendText }}</span>
        </div>
      </div>
    </div>
  </el-card>
</template>

<script>
export default {
  name: 'StatisticsCard',
  props: {
    title: {
      type: String,
      required: true
    },
    value: {
      type: [String, Number],
      required: true
    },
    icon: {
      type: String,
      required: true
    },
    iconColor: {
      type: String,
      default: '#409EFF'
    },
    trend: {
      type: String,
      default: 'up' // up, down, stable
    },
    trendText: {
      type: String,
      default: ''
    }
  },
  computed: {
    trendClass() {
      return {
        'trend-up': this.trend === 'up',
        'trend-down': this.trend === 'down',
        'trend-stable': this.trend === 'stable'
      }
    },
    trendIcon() {
      switch (this.trend) {
        case 'up':
          return 'el-icon-top'
        case 'down':
          return 'el-icon-bottom'
        default:
          return 'el-icon-minus'
      }
    }
  }
}
</script>

<style scoped>
.statistics-card {
  height: 120px;
  cursor: pointer;
  transition: all 0.3s;
}

.statistics-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-header {
  display: flex;
  align-items: center;
}

.card-icon {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
}

.card-icon i {
  font-size: 24px;
  color: white;
}

.card-content {
  flex: 1;
}

.card-title {
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
}

.card-value {
  font-size: 28px;
  font-weight: bold;
  color: #333;
  margin-bottom: 4px;
}

.card-trend {
  font-size: 12px;
  display: flex;
  align-items: center;
}

.trend-up {
  color: #67C23A;
}

.trend-down {
  color: #F56C6C;
}

.trend-stable {
  color: #909399;
}

.card-trend i {
  margin-right: 4px;
}
</style>